//
//  KoiBaseView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 02.04.25.
//

import Foundation
import SwiftUI

extension View {
    
    var uid: String {
        return KoiAccountingUserManager.standard.userId()
    }
    
    var bookId: String {
        return BookManager.standard.currentBookId()
    }
    
    var isTrail: Bool {
        return KoiAccountingUserManager.standard.isTrail()
    }
    
    func koiListRowClear() -> some View {
        return self
            .listRowSeparator(.hidden)
            .listRowInsets(EdgeInsets())
            .listRowBackground(Color.clear)
    }
    
    func koiItemRowStyle() -> some View {
        return self
            .padding(EdgeInsets(top: 20, leading: 14, bottom: 20, trailing: 10))
            .background(Color.koiColorBackgroundItem)
            .cornerRadius(16)
            .padding(.vertical, 5)
    }
    
    func showTrialGuide(isShow:Binding<Bool>) -> some View {
        return self.actionSheet(isPresented: isShow) {
            ActionSheet(
                title: Text("登录解锁锦鲤记账的完整服务"),
                buttons: [
                    .default(Text("去登录"), action: {
                        KoiEvent.toLogin.send()
                    }),
                    .cancel(Text("取消"))
                ]
            )
        }
    }
    
    func ActionSheetGrialGuide() -> ActionSheet {
        return ActionSheet(
            title: Text("登录解锁锦鲤记账的完整服务"),
            buttons: [
                .default(Text("去登录"), action: {
                    KoiEvent.toLogin.send()
                }),
                .cancel(Text("取消"))
            ]
        )
    }
}
